package com.ruoyi.project.mapper;

import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.domainenum.FinSubjectType;
import com.ruoyi.project.domain.FinSubject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 科目Mapper接口
 *
 * @author abel
 * @date 2024-10-15
 */
public interface FinSubjectMapper extends BaseMapper<FinSubject>
{

    /**
     * 查询科目列表
     *
     * @param finSubject 科目
     * @return 科目集合
     */
    List<FinSubject> selectFinSubjectList(FinSubject finSubject);

    /**
     * 删除科目
     *
     * @param id 科目ID
     * @return 结果
     */
    public int deleteFinSubjectById(Long id);

    /**
     * 批量删除科目
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteFinSubjectByIds(Long[] ids);

    @Select("select count(*) from fin_subject where parent_id=#{parentId}")
    int countByParentId(@Param("parentId") Long parentId);

    @Select("select * from fin_subject where package_id=#{packageId} order by code asc")
    List<FinSubject> listByPackageId(@Param("packageId") Long packageId);

    @Select("select * from fin_subject where package_id=#{packageId} and subject_type=#{subjectType} order by code asc")
    List<FinSubject> listBySubjectTypeAndPackageId(@Param("subjectType")FinSubjectType subjectType, @Param("packageId") Long packageId);

    @Update("update fin_subject set subject_level=#{subjectLevel} where id=#{id} ")
    int updateSubjectLevel(@Param("id")Long id,@Param("subjectLevel") Integer subjectLevel);
}
